package at.fhj.swd;

import java.util.Comparator;

/**
 * Implementation of Comparator Class SortByPrice.
 * Class implements interface Comparator, objects of type <code>Rose</code> are getting compared by price.
 * 
 * @author  bernadette.pecovnik
 * @version 1.0
 */
public class SortByPrice implements Comparator<Rose> {

	/**
	 * Compares two roses by prices.
	 * 
	 * @return int value:    1: price of first rose is greater than price of second rose
	 *                     - 1: price of first rose is smaller than price of second rose
	 *                       0: price of first rose is equal to price of second rose
	 */
	@Override
	public int compare(Rose o1, Rose o2) {
		// price of first rose is greater than price of second rose
		if (o1.getPrice() > o2.getPrice()){
			return 1;
		}
		// price of first rose is smaller than price of second rose
		if (o1.getPrice() < o2.getPrice()){
			return -1;
		}
		// price of first rose is equal to price of second rose
		if (o1.getPrice() == o2.getPrice()){
			return 0;
		}
		return 0;
	}

}
